Create and format measures for report dashboard
10
In Power BI Desktop, Measures calculate a result from an expression formula known as Data Analysis Expressions (DAX) formula language.

See steps to create and format the measures needed for this report below.
Step 1: Let us create our first measure; Total Number of Accidents. Right click on 'US_Accidents_Dec20', then click 'New Measure' . Copy and Paste the DAX equation below, then click on the
icon (see GIF below)
TotalAcc = COUNT(US_Accidents_Dec20[ID])
Step 2: Now let us do a neat trick to keep all our measures organized. Click 'Enter Data' on the home screen, type '1' in the column1, then type 'MyMeasures' in the Name, then click 'Load' (See GIF below)
Now click on our new measure 'TotalAcc', click on the Home table drop down, then move to 'Mymeasures' home table. (see screenshot below)
Now right click on 'Column1' under the 'MyMeasures' table and click delete. leaving only the 'TotalAcc' measure. Then click on show/hide pane to show and hide the Fields tab.
This will refresh the tab and move our 'MyMeasures' table to the top. (See GIF below)
Now we can create all our measures under 'MyMeasures'
Step 3: See a list of all the measures we need for this dashboard below. For each measure, right click on the 'MyMeasures' table then click 'New Measure', then copy and paste the DAX equation for each measure below followed by the
icon. An example is shown in the GIF below for Accidents Per Day.
List of Measures
1. AccidentsPerDay = [TotalAcc] / COUNT('Date'[Date])
2. LYAccidentPerDay = CALCULATE([AccidentsPerDay], SAMEPERIODLASTYEAR('Date'[Date]))
3. DiffAccidentPerDay = [AccidentsPerDay] -[LYAccidentPerDay]
4. %YOYAccidentsPerDay = DIVIDE([DiffAccidentPerDay], [LYAccidentPerDay],0)
5. %YOYPerDayIndicator = SWITCH(
TRUE(),
[%YOYAccidentsPerDay]>0, UNICHAR(9650),
[%YOYAccidentsPerDay]<0, UNICHAR(9660),
BLANK())
6. HighSeverity = CALCULATE(COUNT(US_Accidents_Dec20[Severity]), FILTER(US_Accidents_Dec20, US_Accidents_Dec20[Severity] = 3))
7. %HighSeverity = DIVIDE([HighSeverity],[TotalAcc])
8. LYHighSeverity = CALCULATE([HighSeverity], SAMEPERIODLASTYEAR('Date'[Date]))
9. DiffHighSeverity = [HighSeverity] - [LYHighSeverity]
10. %YOYHighSeverity = DIVIDE([DiffHighSeverity], [LYHighSeverity], 0)
11. HighSeverityPerDay = [%HighSeverity] * [AccidentsPerDay]
12. %YOYHSIndicator = SWITCH(
TRUE(),
[%YOYHighSeverity]>0, UNICHAR(9650),
[%YOYHighSeverity]<0, UNICHAR(9660),
BLANK())
Step 4: After creating the measures, some of them needs to be formatted. To format a measure, click on the measure, then the 'Measure tools' will appear on top of the page, then you can format based on your preference and click on the
icon when done. An example is shown in the GIF below for %HighSeverity. Here we will format by clicking on the % sign and reducing the decimal places to 1. Repeat the steps in the GIF below to format '%YOYAccidentsPerDay'
and '%YOYHighSeverity'
See screenshot below to format AccidentsPerDay. Repeat the steps to format LYAccidentPerDay, DiffAccidentPerDay, DiffHighSeverity, HighSeverity, LYHighSeverity, and HighSeverityPerDay.
Create Measures for Data analysis in Power BI Desktop
Power BI Masterclass - beginners to advanced Microsoft Power BI Created by Dan We on www.udemy.com was a helpful tool in understanding some concepts of Power BI. Note that there are a number of other free resources out there, but you can check it out below!
https://www.udemy.com/course/power-bi-masterclass-beginners-to-advanced/